﻿@model PhoneBilling.Models.DiscountModel
@{
    ViewBag.Title = "优惠表编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    $(document).ready(
    function () {


        $(".areaType").attr("disabled", $(".s2").attr("checked") == "checked");
        $(".t2").attr("disabled", $(".s1").attr("checked") == "checked");
    }
    );


    function changeAreaType() {
        var str = "";
        $(".areaType").each(function () {
            if ($(this).attr("checked") == "checked") {
                str += $(this).attr("id");
            }
        });
        $("#areaType").val(str);
    }

    function state1() {
        $(".areaType").attr("disabled", $(".s1").attr("checked") == "undifined");
        $(".t2").attr("disabled", $(".s1").attr("checked") == "checked");
    }
    function state2() {
        $(".areaType").attr("disabled", $(".s2").attr("checked") == "checked");
        $(".t2").attr("disabled", $(".s2").attr("checked") == "undifined");
    }
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnConfirm").ligerButton(
        {
            click: function () {
                $('form').submit();
            }
        });

        $("#date1").ligerDateEditor({ showTime: true, label: '生效日期', initValue: '@Model.生效日期.ToString("yyyy-MM-dd HH:mm")', format: "yyyy-MM-dd hh:mm" });
        $("#date2").ligerDateEditor({ showTime: true, label: '失效日期', initValue: '@Model.失效日期.ToString("yyyy-MM-dd HH:mm")', format: "yyyy-MM-dd hh:mm" });
    });
    
</script>
@using (Html.BeginForm())
{ 
    <div class="discount_edit">
        <div class="system_input_contain">
            @Html.HiddenFor(m => m.ItemNo)
            @Html.HiddenFor(m => m.IsNew)
            @Html.LabelFor(m => m.优惠名称)
            @Html.TextBoxFor(m => m.优惠名称)
            @Html.ValidationMessageFor(m => m.优惠名称, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.LabelFor(m => m.起始时间)
            @Html.TextBox("起始时间", Model.起始时间.ToString("HH:mm:ss"))
            @Html.ValidationMessageFor(m => m.起始时间, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.LabelFor(m => m.终止时间)
            @Html.TextBox("终止时间", Model.终止时间.ToString("HH:mm:ss"))
            @Html.ValidationMessageFor(m => m.终止时间, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            <div class="system_checkbox">
                @Html.RadioButtonFor(m => m.折扣类别, "话类", new { onclick = "state1()", @class = "s1" })
                @Html.LabelFor(m => m.优惠话类)
                @Html.HiddenFor(m => m.优惠话类, new { id = "areaType" })
                @for (int i = 0; i < Model.优惠话类List.Count; i++)
                {
                    <div class="system_checkbox">
                        @Html.CheckBoxFor(m => m.优惠话类List[i].IsSelected, new { onclick = "changeAreaType()", @class = "areaType", id = Model.优惠话类List[i].ID })
                        @Html.Label(string.Format(" {0} ", Model.优惠话类List[i].Name))
                    </div>
                }
            </div>
        </div>
        <div class="system_input_contain">
            <div class="system_checkbox">
                @Html.RadioButtonFor(m => m.折扣类别, "区号", new { onclick = "state2()", @class = "s2" })
                @Html.LabelFor(m => m.优惠区号)
                @Html.TextBoxFor(m => Model.优惠区号, new { @class = "t2" })
            </div>
        </div>
        <div class="system_input_contain">
            @Html.LabelFor(m => m.基本费折扣)
            @Html.TextBox("基本费折扣", Model.基本费折扣)
            @Html.ValidationMessageFor(m => m.基本费折扣, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.LabelFor(m => m.附加费折扣)
            @Html.TextBox("附加费折扣", Model.附加费折扣)
            @Html.ValidationMessageFor(m => m.附加费折扣, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.LabelFor(m => m.服务费折扣)
            @Html.TextBox("服务费折扣", Model.服务费折扣)
            @Html.ValidationMessageFor(m => m.服务费折扣, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.TextBox("生效日期", Model.生效日期, new { @id = "date1" }) 
            @Html.ValidationMessageFor(m => m.生效日期, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            @Html.TextBox("失效日期", Model.失效日期, new { @id = "date2" })
            @Html.ValidationMessageFor(m => m.失效日期, new { style = "color:Red" })
        </div>
        <div class="system_input_contain">
            <input type="button" id="btnConfirm" value="确定" />
        </div>
    </div>
}
